/**
 * Copyright &copy; 2018-2018 <a href="#">聚成科技</a> All rights reserved.
 */
package com.jckj.core.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jckj.core.annotation.CurrentDataSource;
import com.jckj.core.dao.NotifyUserViewMapper;
import com.jckj.core.db.DataSourceEnum;
import com.jckj.core.entity.NotifyUserView;
import com.jckj.core.entity.NotifyUserViewExample;
import com.jckj.core.exception.ServiceException;
import com.jckj.core.service.NotifyUserViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author :liukuan
 * @date :2018-02-07
 */
@Service
@Transactional(readOnly = true,rollbackFor = ServiceException.class)
public class NotifyUserViewServiceImpl implements NotifyUserViewService {

    @Autowired
    private NotifyUserViewMapper notifyUserViewMapper;
    /**
     * @param notifyId
     * @return
     */
    @Override
    @CurrentDataSource(DataSourceEnum.SLAVE)
    public NotifyUserView findById(String notifyId) {
        NotifyUserViewExample example=new NotifyUserViewExample();
        NotifyUserViewExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(notifyId);
        return notifyUserViewMapper.selectByExample(example).get(0);
    }

    /**
     *
     * @param userId
     * @return
     */
    @Override
    @CurrentDataSource(DataSourceEnum.SLAVE)
    public List<NotifyUserView> findUserId(String userId){
        NotifyUserViewExample example=new NotifyUserViewExample();
        NotifyUserViewExample.Criteria criteria = example.createCriteria();
        criteria.andUserIdEqualTo(userId);
        List<NotifyUserView> notifyUserViews = notifyUserViewMapper.selectByExample(example);
        return notifyUserViews;
    }














}
